<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>alertmanager钉钉报警 | Alexcld</title><meta name="keywords" content="alertmanager钉钉报警"><meta name="author" content="Alex"><meta name="copyright" content="Alex"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="钉钉报警插件已打包在镜像，不想麻烦的可以直接pull其他两个平台实时同步 个人Blog：https:&#x2F;&#x2F;alexcld.com CSDN：https:&#x2F;&#x2F;blog.csdn.net&#x2F;weixin_45509582  加密token 1echo -n &#39;token&#39; | base64 alertGo-deployment.yaml 12345678910111213141516171">
<meta property="og:type" content="article">
<meta property="og:title" content="alertmanager钉钉报警">
<meta property="og:url" content="http://blogtest.alexcld.com/posts/6543.html">
<meta property="og:site_name" content="Alexcld">
<meta property="og:description" content="钉钉报警插件已打包在镜像，不想麻烦的可以直接pull其他两个平台实时同步 个人Blog：https:&#x2F;&#x2F;alexcld.com CSDN：https:&#x2F;&#x2F;blog.csdn.net&#x2F;weixin_45509582  加密token 1echo -n &#39;token&#39; | base64 alertGo-deployment.yaml 12345678910111213141516171">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img.alexcld.com/img/233339-1606836819ad92.jpg">
<meta property="article:published_time" content="2021-07-27T06:37:35.000Z">
<meta property="article:modified_time" content="2021-08-02T08:13:20.000Z">
<meta property="article:author" content="Alex">
<meta property="article:tag" content="alertmanager钉钉报警">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img.alexcld.com/img/233339-1606836819ad92.jpg"><link rel="shortcut icon" href="https://img.alexcld.com/img/author.png"><link rel="canonical" href="http://blogtest.alexcld.com/posts/6543"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?ed29f24d552b68e914260fcff2860767";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'alertmanager钉钉报警',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-08-02 16:13:20'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.2.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://img.alexcld.com/img/author.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">29</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">29</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/download"><i class="fa-fw fa fa-download"></i><span> 下载</span></a></div><div class="menus_item"><a class="site-page" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 追剧怪</span></a></div><div class="menus_item"><a class="site-page" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 博主</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://img.alexcld.com/img/233339-1606836819ad92.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Alexcld</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/download"><i class="fa-fw fa fa-download"></i><span> 下载</span></a></div><div class="menus_item"><a class="site-page" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 追剧怪</span></a></div><div class="menus_item"><a class="site-page" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 博主</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">alertmanager钉钉报警</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-07-27T06:37:35.000Z" title="发表于 2021-07-27 14:37:35">2021-07-27</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-08-02T08:13:20.000Z" title="更新于 2021-08-02 16:13:20">2021-08-02</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>9分钟</span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="钉钉报警插件已打包在镜像，不想麻烦的可以直接pull"><a href="#钉钉报警插件已打包在镜像，不想麻烦的可以直接pull" class="headerlink" title="钉钉报警插件已打包在镜像，不想麻烦的可以直接pull"></a>钉钉报警插件已打包在镜像，不想麻烦的可以直接pull</h1><h2 id="其他两个平台实时同步"><a href="#其他两个平台实时同步" class="headerlink" title="其他两个平台实时同步"></a>其他两个平台实时同步</h2><ul>
<li>个人Blog：<a target="_blank" rel="noopener" href="https://alexcld.com/">https://alexcld.com</a></li>
<li>CSDN：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_45509582">https://blog.csdn.net/weixin_45509582</a></li>
</ul>
<p>加密token</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">echo -n &#39;token&#39; | base64</span><br></pre></td></tr></table></figure>
<p>alertGo-deployment.yaml</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br></pre></td><td class="code"><pre><span class="line">apiVersion: v1</span><br><span class="line">kind: Secret</span><br><span class="line">metadata:</span><br><span class="line">  name: dd-token</span><br><span class="line">  namespace: ops</span><br><span class="line">type: Opaque</span><br><span class="line">data:</span><br><span class="line">  token: &#39;加密后的token&#39;</span><br><span class="line">---</span><br><span class="line">apiVersion: apps&#x2F;v1</span><br><span class="line">kind: Deployment</span><br><span class="line">metadata:</span><br><span class="line">  name: alertgo</span><br><span class="line">  namespace: ops</span><br><span class="line">spec:</span><br><span class="line">  selector:</span><br><span class="line">    matchLabels:</span><br><span class="line">      app: alertgo</span><br><span class="line">  replicas: 1</span><br><span class="line">  template:</span><br><span class="line">    metadata:</span><br><span class="line">      labels:</span><br><span class="line">        app: alertgo</span><br><span class="line">    spec:</span><br><span class="line">      containers:</span><br><span class="line">        - name: alertgo</span><br><span class="line">          image: alexcld&#x2F;alertgo:v3</span><br><span class="line">          env:</span><br><span class="line">          - name: token</span><br><span class="line">            valueFrom:</span><br><span class="line">              secretKeyRef:</span><br><span class="line">                name: dd-token</span><br><span class="line">                key: token</span><br><span class="line">          ports:</span><br><span class="line">            - containerPort: 8088</span><br><span class="line">          livenessProbe:</span><br><span class="line">            httpGet:</span><br><span class="line">              path: &#x2F;</span><br><span class="line">              port: 8088</span><br><span class="line">            initialDelaySeconds: 30</span><br><span class="line">            periodSeconds: 10</span><br><span class="line">            successThreshold: 1</span><br><span class="line">            failureThreshold: 3</span><br><span class="line">            timeoutSeconds: 1</span><br><span class="line">          readinessProbe:</span><br><span class="line">            httpGet:</span><br><span class="line">              path: &#x2F;</span><br><span class="line">              port: 8088</span><br><span class="line">            initialDelaySeconds: 30</span><br><span class="line">            periodSeconds: 10</span><br><span class="line">            successThreshold: 1</span><br><span class="line">            failureThreshold: 3</span><br><span class="line">            timeoutSeconds: 1</span><br><span class="line">          lifecycle:</span><br><span class="line">            preStop:</span><br><span class="line">              exec:</span><br><span class="line">                command: [&quot;&#x2F;bin&#x2F;bash&quot;,&quot;-c&quot;,&quot;sleep 20&quot;]</span><br><span class="line">---</span><br><span class="line">apiVersion: v1</span><br><span class="line">kind: Service</span><br><span class="line">metadata:</span><br><span class="line">  name: alertgo</span><br><span class="line">  namespace: ops</span><br><span class="line">spec:</span><br><span class="line">  selector:</span><br><span class="line">    app: alertgo</span><br><span class="line">  ports:</span><br><span class="line">    - port: 80</span><br><span class="line">      targetPort: 8088</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>kubectl apply -f alertGo-deployment.yaml</p>
<h2 id="修改alertmanager-configmap-yaml"><a href="#修改alertmanager-configmap-yaml" class="headerlink" title="修改alertmanager-configmap.yaml"></a>修改alertmanager-configmap.yaml</h2><p><img src="https://img-blog.csdnimg.cn/a516c430f9564610aae3e311fb999fd0.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTUwOTU4Mg==,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">webhook_configs:</span><br><span class="line">      - url: &#39;http:&#x2F;&#x2F;clusterIP&#x2F;Alert&#39;</span><br><span class="line">        send_resolved: true</span><br></pre></td></tr></table></figure>
<p>至此完成</p>
<h1 id="go环境部署及打包钉钉报警插件"><a href="#go环境部署及打包钉钉报警插件" class="headerlink" title="go环境部署及打包钉钉报警插件"></a>go环境部署及打包钉钉报警插件</h1><h2 id="其他两个平台实时同步-1"><a href="#其他两个平台实时同步-1" class="headerlink" title="其他两个平台实时同步"></a>其他两个平台实时同步</h2><ul>
<li>个人Blog：<a target="_blank" rel="noopener" href="https://alexcld.com/">https://alexcld.com</a></li>
<li>CSDN：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_45509582">https://blog.csdn.net/weixin_45509582</a><h2 id="linux安装go1-13-10"><a href="#linux安装go1-13-10" class="headerlink" title="linux安装go1.13.10"></a>linux安装go1.13.10</h2></li>
</ul>
<p>下载解压</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd &#x2F;opt &amp;&amp; wget https:&#x2F;&#x2F;golang.org&#x2F;dl&#x2F;go1.13.10.linux-amd64.tar.gz</span><br><span class="line">#解压至&#x2F;usr&#x2F;local</span><br><span class="line">tar -zxvf go1.13.10.linux-amd64.tar.gz</span><br></pre></td></tr></table></figure>
<p>创建/opt/gocode/{src,bin,pkg}，用于设置GOPATH为/opt/gocode</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p &#x2F;opt&#x2F;gocode&#x2F;&#123;src,bin,pkg&#125;</span><br><span class="line"></span><br><span class="line">&#x2F;opt&#x2F;gocode&#x2F;</span><br><span class="line">├── bin</span><br><span class="line">├── pkg</span><br><span class="line">└── src</span><br></pre></td></tr></table></figure>
<p>修改/etc/profile系统环境变量文件，写入GOPATH信息以及go sdk路径</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">export GOROOT&#x3D;&#x2F;opt&#x2F;go           #Golang源代码目录，安装目录</span><br><span class="line">export GOPATH&#x3D;&#x2F;opt&#x2F;gocode        #Golang项目代码目录</span><br><span class="line">export PATH&#x3D;$GOROOT&#x2F;bin:$PATH    #Linux环境变量</span><br><span class="line">export GOBIN&#x3D;$GOPATH&#x2F;bin        #go install后生成的可执行命令存放路径</span><br><span class="line"># 保存退出后source一下</span><br><span class="line">source &#x2F;etc&#x2F;profile</span><br></pre></td></tr></table></figure>
<p>执行go version</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost gocode]# go version</span><br><span class="line">go version go1.13.10 linux&#x2F;amd64</span><br></pre></td></tr></table></figure>
<h2 id="运行程序并打包"><a href="#运行程序并打包" class="headerlink" title="运行程序并打包"></a>运行程序并打包</h2><h3 id="安装gin-web框架"><a href="#安装gin-web框架" class="headerlink" title="安装gin web框架"></a>安装gin web框架</h3><p>爬过梯子的可以直接安装，不再赘述如何爬梯子，如果没有爬梯子的话 需要设置下GOPROXY</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">golang 1.13 可以直接执行：</span><br><span class="line"></span><br><span class="line">七牛云</span><br><span class="line">go env -w GO111MODULE&#x3D;on</span><br><span class="line">go env -w GOPROXY&#x3D;https:&#x2F;&#x2F;goproxy.cn,direct</span><br><span class="line"></span><br><span class="line">阿里云</span><br><span class="line">go env -w GO111MODULE&#x3D;on</span><br><span class="line">go env -w GOPROXY&#x3D;https:&#x2F;&#x2F;mirrors.aliyun.com&#x2F;goproxy&#x2F;,direct</span><br></pre></td></tr></table></figure>
<p>安装gin依赖</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">go get -u github.com&#x2F;gin-gonic&#x2F;gin</span><br></pre></td></tr></table></figure>
<p>创建go文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p $GOPATH&#x2F;alertgo &amp;&amp; cd $GOPATH&#x2F;alertgo</span><br><span class="line">touch alertGo.go</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br></pre></td><td class="code"><pre><span class="line">package main</span><br><span class="line"></span><br><span class="line">import (</span><br><span class="line">	&quot;bytes&quot;</span><br><span class="line">	&quot;encoding&#x2F;json&quot;</span><br><span class="line">	&quot;fmt&quot;</span><br><span class="line">	&quot;net&#x2F;http&quot;</span><br><span class="line">	&quot;os&quot;</span><br><span class="line">	&quot;strings&quot;</span><br><span class="line">	&quot;time&quot;</span><br><span class="line"></span><br><span class="line">	&quot;github.com&#x2F;gin-gonic&#x2F;gin&quot;</span><br><span class="line">)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;const (</span><br><span class="line">&#x2F;&#x2F;	webHook_Alert &#x3D; &quot;https:&#x2F;&#x2F;oapi.dingtalk.com&#x2F;robot&#x2F;send?access_token&#x3D;724402cd85e7e80aa5bbbb7d7a89c74db6a3a8bd8fac4c91923ed3f906664ba4&quot;</span><br><span class="line">&#x2F;&#x2F;)</span><br><span class="line">type Message struct &#123;</span><br><span class="line">	MsgType string &#96;json:&quot;msgtype&quot;&#96;</span><br><span class="line">	Text    struct &#123;</span><br><span class="line">		Content               string &#96;json:&quot;content&quot;&#96;</span><br><span class="line">		Mentioned_list        string &#96;json:&quot;mentioned_list&quot;&#96;</span><br><span class="line">		Mentioned_mobile_list string &#96;json:&quot;mentioned_mobile_list&quot;&#96;</span><br><span class="line">	&#125; &#96;json:&quot;text&quot;&#96;</span><br><span class="line">&#125;</span><br><span class="line">type Alert struct &#123;</span><br><span class="line">	Labels      map[string]string &#96;json:&quot;labels&quot;&#96;</span><br><span class="line">	Annotations map[string]string &#96;json:annotations&#96;</span><br><span class="line">	StartsAt    time.Time         &#96;json:&quot;startsAt&quot;&#96;</span><br><span class="line">	EndsAt      time.Time         &#96;json:&quot;endsAt&quot;&#96;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;通知消息结构体</span><br><span class="line">type Notification struct &#123;</span><br><span class="line">	Version           string            &#96;json:&quot;version&quot;&#96;</span><br><span class="line">	GroupKey          string            &#96;json:&quot;groupKey&quot;&#96;</span><br><span class="line">	Status            string            &#96;json:&quot;status&quot;&#96;</span><br><span class="line">	Receiver          string            &#96;json:receiver&#96;</span><br><span class="line">	GroupLabels       map[string]string &#96;json:groupLabels&#96;</span><br><span class="line">	CommonLabels      map[string]string &#96;json:commonLabels&#96;</span><br><span class="line">	CommonAnnotations map[string]string &#96;json:commonAnnotations&#96;</span><br><span class="line">	ExternalURL       string            &#96;json:externalURL&#96;</span><br><span class="line">	Alerts            []Alert           &#96;json:alerts&#96;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;获取报警信息</span><br><span class="line">func getAlertInfo(notification Notification) string &#123;</span><br><span class="line">	var m Message</span><br><span class="line">	m.MsgType &#x3D; &quot;text&quot;</span><br><span class="line">	&#x2F;&#x2F;告警消息</span><br><span class="line">	&#x2F;&#x2F;重新定义报警消息</span><br><span class="line">	var newbuffer bytes.Buffer</span><br><span class="line">	&#x2F;&#x2F;定义恢复消息</span><br><span class="line">	var recoverbuffer bytes.Buffer</span><br><span class="line">	fmt.Println(notification)</span><br><span class="line">	fmt.Println(notification.Status)</span><br><span class="line">	if notification.Status &#x3D;&#x3D; &quot;resolved&quot; &#123;</span><br><span class="line">		for _, alert :&#x3D; range notification.Alerts &#123;</span><br><span class="line">			recoverbuffer.WriteString(fmt.Sprintf(&quot;状态已经恢复!!!!\n&quot;))</span><br><span class="line">			recoverbuffer.WriteString(fmt.Sprintf(&quot; **项目: 恢复时间:**%s\n\n&quot;, alert.StartsAt.Add(8*time.Hour).Format(&quot;2006-01-02 15:04:05&quot;)))</span><br><span class="line">			recoverbuffer.WriteString(fmt.Sprintf(&quot;项目: 告警主题: %s \n&quot;, alert.Annotations[&quot;summary&quot;]))</span><br><span class="line"></span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		for _, alert :&#x3D; range notification.Alerts &#123;</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;Start&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D; \n&quot;))</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot;项目: 告警程序：prometheus_alert_email \n&quot;))</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot;项目: 告警级别: %s \n&quot;, alert.Labels[&quot;severity&quot;]))</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot;项目: 告警类型: %s \n&quot;, alert.Labels[&quot;alertname&quot;]))</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot;项目: 故障主机: %s \n&quot;, alert.Labels[&quot;instance&quot;]))</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot;项目: 告警主题: %s \n&quot;, alert.Annotations[&quot;summary&quot;]))</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot;项目: 告警详情: %s \n&quot;, alert.Annotations[&quot;description&quot;]))</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot; **项目: 开始时间:**%s\n\n&quot;, alert.StartsAt.Add(8*time.Hour).Format(&quot;2006-01-02 15:04:05&quot;)))</span><br><span class="line">			newbuffer.WriteString(fmt.Sprintf(&quot;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;End&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D; \n&quot;))</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	if notification.Status &#x3D;&#x3D; &quot;resolved&quot; &#123;</span><br><span class="line">		m.Text.Content &#x3D; recoverbuffer.String()</span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		m.Text.Content &#x3D; newbuffer.String()</span><br><span class="line">	&#125;</span><br><span class="line">	jsons, err :&#x3D; json.Marshal(m)</span><br><span class="line">	if err !&#x3D; nil &#123;</span><br><span class="line">		fmt.Println(&quot;解析发送钉钉的信息有问题!!!!&quot;)</span><br><span class="line">	&#125;</span><br><span class="line">	resp :&#x3D; string(jsons)</span><br><span class="line">	return resp</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;钉钉报警</span><br><span class="line">func SendAlertDingMsg(msg string) &#123;</span><br><span class="line">	defer func() &#123;</span><br><span class="line">		if err :&#x3D; recover(); err !&#x3D; nil &#123;</span><br><span class="line">			fmt.Println(&quot;err&quot;)</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;()</span><br><span class="line">	token :&#x3D; os.Getenv(&quot;token&quot;)</span><br><span class="line">	webHook_Alert :&#x3D; &quot;https:&#x2F;&#x2F;oapi.dingtalk.com&#x2F;robot&#x2F;send?access_token&#x3D;&quot; + token</span><br><span class="line">	fmt.Println(&quot;开始发送报警消息!!!&quot;)</span><br><span class="line">	fmt.Println(webHook_Alert)</span><br><span class="line">	&#x2F;&#x2F;content :&#x3D; &#96;&#123;&quot;msgtype&quot;: &quot;text&quot;,</span><br><span class="line">	&#x2F;&#x2F;	&quot;text&quot;: &#123;&quot;content&quot;: &quot;&#96; + msg + &#96;&quot;&#125;</span><br><span class="line">	&#x2F;&#x2F;&#125;&#96;</span><br><span class="line"></span><br><span class="line">	&#x2F;&#x2F;创建一个请求</span><br><span class="line">	req, err :&#x3D; http.NewRequest(&quot;POST&quot;, webHook_Alert, strings.NewReader(msg))</span><br><span class="line">	if err !&#x3D; nil &#123;</span><br><span class="line">		fmt.Println(err)</span><br><span class="line">		fmt.Println(&quot;钉钉报警请求异常&quot;)</span><br><span class="line">	&#125;</span><br><span class="line">	client :&#x3D; &amp;http.Client&#123;&#125;</span><br><span class="line">	&#x2F;&#x2F;设置请求头</span><br><span class="line">	req.Header.Set(&quot;Content-Type&quot;, &quot;application&#x2F;json; charset&#x3D;utf-8&quot;)</span><br><span class="line">	&#x2F;&#x2F;发送请求</span><br><span class="line">	resp, err :&#x3D; client.Do(req)</span><br><span class="line">	if err !&#x3D; nil &#123;</span><br><span class="line">		&#x2F;&#x2F; handle error</span><br><span class="line">		fmt.Println(err)</span><br><span class="line">		fmt.Println(&quot;顶顶报发送异常!!!&quot;)</span><br><span class="line">	&#125;</span><br><span class="line">	defer resp.Body.Close()</span><br><span class="line">&#125;</span><br><span class="line">func AlertInfo(c *gin.Context) &#123;</span><br><span class="line">	var notification Notification</span><br><span class="line">	fmt.Println(&quot;接收到的信息是....&quot;)</span><br><span class="line">	fmt.Println(notification)</span><br><span class="line">	err :&#x3D; c.BindJSON(&amp;notification)</span><br><span class="line">	fmt.Printf(&quot;%#v&quot;, notification)</span><br><span class="line">	if err !&#x3D; nil &#123;</span><br><span class="line">		fmt.Println(&quot;绑定信息错误!!!&quot;)</span><br><span class="line">		c.JSON(http.StatusBadRequest, gin.H&#123;&quot;error&quot;: err.Error()&#125;)</span><br><span class="line">		return</span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		fmt.Println(&quot;绑定信息成功&quot;)</span><br><span class="line">	&#125;</span><br><span class="line">	fmt.Println(&quot;绑定信息成功!!!&quot;)</span><br><span class="line">	msg :&#x3D; getAlertInfo(notification)</span><br><span class="line">	fmt.Println(&quot;打印的信息是.....&quot;)</span><br><span class="line">	fmt.Println(msg)</span><br><span class="line">	SendAlertDingMsg(msg)</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line">func main() &#123;</span><br><span class="line">	t :&#x3D; gin.Default()</span><br><span class="line">	t.POST(&quot;&#x2F;Alert&quot;, AlertInfo)</span><br><span class="line">	t.GET(&quot;&#x2F;&quot;, func(c *gin.Context) &#123;</span><br><span class="line">		c.String(http.StatusOK, &#96;&lt;h1&gt;关于alertmanager实现钉钉报警的方法V6！！！&lt;&#x2F;h1&gt;&#96;+&quot;\n新增了报警恢复机制！！！&quot;)</span><br><span class="line">	&#125;)</span><br><span class="line">	t.Run(&quot;:8088&quot;)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>最后将go文件打包为linux二进制可运行程序</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">go build alertGo.go</span><br></pre></td></tr></table></figure>
<p>运行alertGo程序</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">###赋权</span><br><span class="line">chmod 775 alertGo</span><br><span class="line">###后台运行</span><br><span class="line">nohup &#x2F;root&#x2F;prometheus&#x2F;alertGo&#x2F;alertGo &gt; alertGo.log 2&gt;&amp;1 &amp;</span><br><span class="line">###查看端口进程</span><br><span class="line">lsof -i:8088</span><br><span class="line">###查看日志</span><br><span class="line">tail -f alertGo.log </span><br></pre></td></tr></table></figure>

<h2 id="修改alertmanager-configmap-yaml-1"><a href="#修改alertmanager-configmap-yaml-1" class="headerlink" title="修改alertmanager-configmap.yaml"></a>修改alertmanager-configmap.yaml</h2><p><img src="https://img-blog.csdnimg.cn/a516c430f9564610aae3e311fb999fd0.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTUwOTU4Mg==,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">webhook_configs:</span><br><span class="line">      - url: &#39;http:&#x2F;&#x2F;xxxxx:8088&#x2F;Alert&#39;</span><br><span class="line">        send_resolved: true</span><br></pre></td></tr></table></figure>
<p>热更新prometheus</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">kubectl apply -f alertmanager-configmap.yaml</span><br><span class="line">###alertmanager clusterIP</span><br><span class="line">curl -X POST http:&#x2F;&#x2F;10.1.229.17&#x2F;-&#x2F;reload  </span><br></pre></td></tr></table></figure>

<p>然后触发报警，钉钉就可以正常收取了，<br><img src="https://img-blog.csdnimg.cn/dfbbf2efe4b446c1bc71a20a54855180.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTUwOTU4Mg==,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>在此感谢<a target="_blank" rel="noopener" href="https://blog.51cto.com/luoguoling">大佬</a>的代码</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Alex</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://blogtest.alexcld.com/posts/6543.html">http://blogtest.alexcld.com/posts/6543.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://blogtest.alexcld.com" target="_blank">Alexcld</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/alertmanager%E9%92%89%E9%92%89%E6%8A%A5%E8%AD%A6/">alertmanager钉钉报警</a></div><div class="post_share"><div class="social-share" data-image="https://img.alexcld.com/img/233339-1606836819ad92.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/63478.html"><img class="prev-cover" src="https://img.alexcld.com/img/231643-159387580391a3.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">k8s+jenkins实现CI，CD</div></div></a></div><div class="next-post pull-right"><a href="/posts/267647.html"><img class="next-cover" src="https://img.alexcld.com/img/nvpu3.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">监控体系部署之后走上了grafana模板踩坑之路</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://img.alexcld.com/img/author.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Alex</div><div class="author-info__description">children don't lie</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">29</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">29</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/alexclownfish"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/alexclownfish" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:ywz0207@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://vue.alexcld.com" target="_blank" title="vue站点"><i class="fab fa-vuejs"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is AKA Alex,respect yeah</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%92%89%E9%92%89%E6%8A%A5%E8%AD%A6%E6%8F%92%E4%BB%B6%E5%B7%B2%E6%89%93%E5%8C%85%E5%9C%A8%E9%95%9C%E5%83%8F%EF%BC%8C%E4%B8%8D%E6%83%B3%E9%BA%BB%E7%83%A6%E7%9A%84%E5%8F%AF%E4%BB%A5%E7%9B%B4%E6%8E%A5pull"><span class="toc-number">1.</span> <span class="toc-text">钉钉报警插件已打包在镜像，不想麻烦的可以直接pull</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%B6%E4%BB%96%E4%B8%A4%E4%B8%AA%E5%B9%B3%E5%8F%B0%E5%AE%9E%E6%97%B6%E5%90%8C%E6%AD%A5"><span class="toc-number">1.1.</span> <span class="toc-text">其他两个平台实时同步</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9alertmanager-configmap-yaml"><span class="toc-number">1.2.</span> <span class="toc-text">修改alertmanager-configmap.yaml</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#go%E7%8E%AF%E5%A2%83%E9%83%A8%E7%BD%B2%E5%8F%8A%E6%89%93%E5%8C%85%E9%92%89%E9%92%89%E6%8A%A5%E8%AD%A6%E6%8F%92%E4%BB%B6"><span class="toc-number">2.</span> <span class="toc-text">go环境部署及打包钉钉报警插件</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%B6%E4%BB%96%E4%B8%A4%E4%B8%AA%E5%B9%B3%E5%8F%B0%E5%AE%9E%E6%97%B6%E5%90%8C%E6%AD%A5-1"><span class="toc-number">2.1.</span> <span class="toc-text">其他两个平台实时同步</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#linux%E5%AE%89%E8%A3%85go1-13-10"><span class="toc-number">2.2.</span> <span class="toc-text">linux安装go1.13.10</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BF%90%E8%A1%8C%E7%A8%8B%E5%BA%8F%E5%B9%B6%E6%89%93%E5%8C%85"><span class="toc-number">2.3.</span> <span class="toc-text">运行程序并打包</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85gin-web%E6%A1%86%E6%9E%B6"><span class="toc-number">2.3.1.</span> <span class="toc-text">安装gin web框架</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9alertmanager-configmap-yaml-1"><span class="toc-number">2.4.</span> <span class="toc-text">修改alertmanager-configmap.yaml</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/5880.html" title="docker-compose部署java前后端分离项目"><img src="https://img.alexcld.com/img/003219-15968179390168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="docker-compose部署java前后端分离项目"/></a><div class="content"><a class="title" href="/posts/5880.html" title="docker-compose部署java前后端分离项目">docker-compose部署java前后端分离项目</a><time datetime="2022-01-17T07:02:14.000Z" title="发表于 2022-01-17 15:02:14">2022-01-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5877.html" title="jenkins多用户权限管理"><img src="https://img.alexcld.com/img/playpiano.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="jenkins多用户权限管理"/></a><div class="content"><a class="title" href="/posts/5877.html" title="jenkins多用户权限管理">jenkins多用户权限管理</a><time datetime="2022-01-17T06:51:58.000Z" title="发表于 2022-01-17 14:51:58">2022-01-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/undefined.html" title="声明式pipeline在k8s中完成自动部署，回滚，钉钉通知"><img src="https://img.alexcld.com/img/catgirl.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="声明式pipeline在k8s中完成自动部署，回滚，钉钉通知"/></a><div class="content"><a class="title" href="/posts/undefined.html" title="声明式pipeline在k8s中完成自动部署，回滚，钉钉通知">声明式pipeline在k8s中完成自动部署，回滚，钉钉通知</a><time datetime="2021-12-10T03:24:28.000Z" title="发表于 2021-12-10 11:24:28">2021-12-10</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5876.html" title="jenkins自动部署版本回滚"><img src="https://img.alexcld.com/img/170734-15694024544d72.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="jenkins自动部署版本回滚"/></a><div class="content"><a class="title" href="/posts/5876.html" title="jenkins自动部署版本回滚">jenkins自动部署版本回滚</a><time datetime="2021-10-09T08:07:14.000Z" title="发表于 2021-10-09 16:07:14">2021-10-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/9424.html" title="win10下使用linux"><img src="https://img.alexcld.com/img/090412-15573638521155.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="win10下使用linux"/></a><div class="content"><a class="title" href="/posts/9424.html" title="win10下使用linux">win10下使用linux</a><time datetime="2021-10-09T08:01:06.000Z" title="发表于 2021-10-09 16:01:06">2021-10-09</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://img.alexcld.com/img/233339-1606836819ad92.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By Alex</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">alexclownfish</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="rightside.chat_btn"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'rdtTOtMkfivtPvkQaaDXmJUd-gzGzoHsz',
      appKey: 'E68vw0GUqAynKmIiHtw9FLRA',
      placeholder: '留下你的看法吧！！',
      avatar: 'monsterid',
      meta: 'nick,mail,link'.split(','),
      pageSize: '10',
      lang: 'zh-CN',
      recordIP: true,
      serverURLs: '',
      emojiCDN: '',
      emojiMaps: "",
      enableQQ: true,
      path: window.location.pathname,
      requiredFields: ["nick,mail"],
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !false) {
  if (false) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js" data-mobile="false" data-text="I,LOVE,YOU" data-fontsize="15px" data-random="false" async="async"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start -->
  <script data-pjax src="https://cdn.jsdelivr.net/gh/Zfour/hexo-github-calendar@1.21/hexo_githubcalendar.js"></script>
  <script data-pjax>
        function GithubCalendarConfig(){
            var git_githubapiurl ="https://python-github-calendar-api.vercel.app/api?alexclownfish";
            var git_color =['#ebedf0', '#fdcdec', '#fc9bd9', '#fa6ac5', '#f838b2', '#f5089f', '#c4067e', '#92055e', '#540336', '#48022f', '#30021f'];
            var git_user ="alexclownfish";
            var parent_div_git = document.getElementById('recent-posts');
            var git_div_html = '<div class="recent-post-item" style="width:100%;height:auto;padding:10px;"><div id="github_loading" style="width:10%;height:100%;margin:0 auto;display: block"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve"><path fill="#d0d0d0" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform></path></svg></div><div id="github_container"></div></div>';
            if(parent_div_git && location.pathname =='/'){
                console.log('已挂载github calendar')
                // parent_div_git.innerHTML=git_div_html+parent_div_git.innerHTML // 无报错，但不影响使用(支持pjax跳转)
                parent_div_git.insertAdjacentHTML("afterbegin",git_div_html) // 有报错，但不影响使用(支持pjax跳转)
            };
            GithubCalendar(git_githubapiurl,git_color,git_user)
        }
        if(document.getElementById('recent-posts')){
            GithubCalendarConfig()
        }
    </script>
    <style>#github_container{min-height:280px}@media screen and (max-width:650px) {#github_container{background-image:;min-height:0px}}</style>
    <style></style><!-- hexo injector body_end end --><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"model":{"jsonPath":"/live2dw/assets/tororo.model.json"},"display":{"position":"left","width":150,"height":300},"mobile":{"show":true},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body></html>